package pl.edu.agh.winmon.hibernate;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * Represents information about computer's CPU. Each session has exactly one
 * information about CPU.
 */
@Entity
@Table(name = "`" + CpuInfo.TABLE_NAME + "`")
public class CpuInfo implements Serializable {

	@Transient
	private static final long serialVersionUID = -8549104632655669165L;

	/**
	 * Table name.
	 */
	@Transient
	public static final String TABLE_NAME = "cpu_info"; //$NON-NLS-1$

	/**
	 * Hibernate's annotation property: id.
	 */
	@Transient
	public static final String PROP_ID = "id"; //$NON-NLS-1$

	/**
	 * Database column name: id;
	 */
	@Transient
	public static final String DB_ID = PROP_ID;

	/**
	 * Hibernate's annotation property: session id.
	 */
	@Transient
	public static final String PROP_SESSION = "session"; //$NON-NLS-1$

	/**
	 * Database column name: session id;
	 */
	@Transient
	public static final String DB_SESSION = "session_id"; //$NON-NLS-1$

	/**
	 * Hibernate's annotation property: cache size.
	 */
	@Transient
	public static final String PROP_CACHE = "cache"; //$NON-NLS-1$

	/**
	 * Database column name: session id;
	 */
	@Transient
	public static final String DB_CACHE = PROP_CACHE;

	/**
	 * Hibernate's annotation property: CPU speed.
	 */
	@Transient
	public static final String PROP_CPU_SPEED = "cpuSpeed"; //$NON-NLS-1$

	/**
	 * Database column name: CPU speed;
	 */
	@Transient
	public static final String DB_CPU_SPEED = "cpu_speed"; //$NON-NLS-1$

	/**
	 * Hibernate's annotation property: CPU model.
	 */
	@Transient
	public static final String PROP_CPU_MODEL = "cpuModel"; //$NON-NLS-1$

	/**
	 * Database column name: CPU model;
	 */
	@Transient
	public static final String DB_CPU_MODEL = "cpu_model"; //$NON-NLS-1$

	/**
	 * Hibernate's annotation property: CPU cores.
	 */
	@Transient
	public static final String PROP_CPU_CORES = "cpuCores"; //$NON-NLS-1$

	/**
	 * Database column name: CPU cores;
	 */
	@Transient
	public static final String DB_CPU_CORES = "cpu_cores"; //$NON-NLS-1$

	/**
	 * Hibernate's annotation property: CPU vendor.
	 */
	@Transient
	public static final String PROP_CPU_VENDOR = "cpuVendor"; //$NON-NLS-1$

	/**
	 * Database column name: CPU vendor;
	 */
	@Transient
	public static final String DB_CPU_VENDOR = "cpu_vendor"; //$NON-NLS-1$

	/**
	 * Id of the session.
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = DB_ID)
	private Long id;

	/**
	 * Session related to information about CPU.
	 */
	@OneToOne(targetEntity = Session.class)
	private Session session;

	/**
	 * Cache size.
	 */
	@Column(name = DB_CACHE)
	private Long cache;

	/**
	 * CPU speed.
	 */
	@Column(name = DB_CPU_SPEED)
	private Integer cpuSpeed;

	/**
	 * CPU model.
	 */
	@Column(name = DB_CPU_MODEL)
	private String cpuModel;

	/**
	 * CPU cores.
	 */
	@Column(name = DB_CPU_CORES)
	private Integer cpuCores;

	/**
	 * CPU vendor.
	 */
	@Column(name = DB_CPU_VENDOR)
	private String cpuVendor;

	/**
	 * Returns id of the session.
	 * 
	 * @return Id of the session.
	 */
	public Long getId() {
		return id;
	}

	/**
	 * Sets id of the session.
	 * 
	 * @param id
	 *            Id of the session,
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * Returns session related to information about CPU.
	 * 
	 * @return Session related to information about CPU.
	 */
	public Session getSession() {
		return session;
	}

	/**
	 * Set session related to information about CPU.
	 * 
	 * @param session
	 *            Session related to information about CPU.
	 */
	public void setSession(Session session) {
		this.session = session;
	}

	/**
	 * Returns cache size.
	 * 
	 * @return Cache size.
	 */
	public Long getCache() {
		return cache;
	}

	/**
	 * Sets cache size.
	 * 
	 * @param cache
	 *            Cache size.
	 */
	public void setCache(Long cache) {
		this.cache = cache;
	}

	/**
	 * Returns CPU speed.
	 * 
	 * @return CPU speed.
	 */
	public Integer getCpuSpeed() {
		return cpuSpeed;
	}

	/**
	 * Sets CPU speed.
	 * 
	 * @param cpuSpeed
	 *            CPU speed.
	 */
	public void setCpuSpeed(Integer cpuSpeed) {
		this.cpuSpeed = cpuSpeed;
	}

	/**
	 * Returns CPU model.
	 * 
	 * @return CPU model.
	 */
	public String getCpuModel() {
		return cpuModel;
	}

	/**
	 * Sets CPU model.
	 * 
	 * @param cpuModel
	 *            CPU model.
	 */
	public void setCpuModel(String cpuModel) {
		this.cpuModel = cpuModel;
	}

	/**
	 * Returns count of CPU cores.
	 * 
	 * @return Count of CPU cores.
	 */
	public Integer getCpuCores() {
		return cpuCores;
	}

	/**
	 * Set amount of CPU cores.
	 * 
	 * @param cpuCores
	 *            Amount of CPU cores.
	 */
	public void setCpuCores(Integer cpuCores) {
		this.cpuCores = cpuCores;
	}

	/**
	 * Returns CPU vendor.
	 * 
	 * @return CPU vendor.
	 */
	public String getCpuVendor() {
		return cpuVendor;
	}

	/**
	 * Sets CPU vendor.
	 * 
	 * @param cpuVendor
	 *            CPU vendor.
	 */
	public void setCpuVendor(String cpuVendor) {
		this.cpuVendor = cpuVendor;
	}

}
